package main;

import javax.microedition.lcdui.Graphics;

/*
 * To change this template, choose Tools | Templates and open the template in
 * the editor.
 */
/**
 *
 * @author chau
 */
public abstract class ShortShowObject {

    private long timeStart;
    private long timeShow;
    public boolean isShow;

    public ShortShowObject() {
    }

    public void show(int timeShow) {
        this.timeStart = System.currentTimeMillis();
        this.timeShow = timeShow;
        isShow = true;
        //  Debug.d("show box");
    }

    public void paint(Graphics g) {
        if (isShow) {
            paintObject(g);
        }
    }

    public abstract void paintObject(Graphics g);

    public abstract void doLoop();

    public abstract void doWhenStop();

    public void run() {
        long currentTime = System.currentTimeMillis();
//        Debug.d("time :"+(currentTime-timeStart));
        if (currentTime - timeStart > timeShow) {
            isShow = false;
            doWhenStop();
        }
        //  Debug.d("run box :" + (currentTime - timeStart));
        doLoop();
    }
}
